<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.PreparedStatement" %><%--
  Created by IntelliJ IDEA.
  User: 给
  Date: 2020/12/8
  Time: 12:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<jsp:useBean id="user" class="com.media.bean.UserBean"></jsp:useBean>
<jsp:setProperty name ="user" property="*"></jsp:setProperty>
<%
    //加载数据库驱动
    Class.forName("com.mysql.jdbc.Driver");

    //建立数据库连接
    String urL ="jdbc:mysql://localhost:3306/book";//数据库 连接地址

    String url;
    Connection connection = DriverManager.getConnection(urL,"root","root");
    //第一 一个root为数据库的用户

    String sqL ="update user set username =?,lianjie =? where id=?";
    String sqU;
    PreparedStatement ps = connection.prepareStatement(sqL);
    ps.setString(1,user.getUsername());
    ps.setString(2,user.getPassword());

    int count=ps.executeUpdate();
    if(count > 0){
        out.print("修改成功");
    }else{
        out.print("修改失败");
    }
    response.setHeader("refresh","3；urL=home2.jsp");

%>